<template>
	<view class="body">
		<xk-header :headerbg="true" :back="true" title="编辑个人资料"></xk-header>
		<view class="list-info">
			<view class="list-item">
				<view>用户名</view>
				<input class="input-text" v-model="userName" type="text" placeholder="请输入用户名" placeholder-style="color:#ccc"/>
			</view>
		</view>

		<view class="common-btn" @click="onSubmit()">确认修改</view>
	</view>
</template>
<script>
	import config from '@/common/config.js'
	import moment from 'moment'

	export default {
		data() {
			return {
				userName: this.$util.getStorage("loginInfo").name
			};
		},
		onLoad(options) {
		},
		methods:{
			onSubmit() {
				if (!this.userName) {
					this.$util.toast("请输入您的用户名")
					return;
				}

				this.$util.post({
					url: "app/mySelf/updateForUserName",
					data: {
						user_name: this.userName
					}
				}).then(res	=> {
					this.$util.toast("修改成功")
					let loginInfo = this.$util.getStorage("loginInfo")
					loginInfo.name = this.userName
					this.$util.setStorage("loginInfo", loginInfo)
					setTimeout(()=>{
						uni.navigateBack()
					}, 500)
				})

			},
		}
	}
</script>

<style lang="scss">

.list-info {
	margin: 20rpx 20rpx 0rpx 20rpx;

	.list-item {
		display: flex;
		background-color: #FFFFFF;
		border-radius: 10rpx;
		font-size: 28rpx;
		padding: 30rpx;
		font-size: 28rpx;
		color: #333;
		align-items: center;

		>view {
			width: 120rpx;
		}

		.input-text {
			color: #333;
			margin-left: 30rpx;
		}
	}
}
</style>
